#include<stdio.h>
#include<unistd.h>
#include<signal.h>

volatile int flag = 0;

void handler(int signal_num)
{
    flag = 1;
    printf("flag:0->1\n");
}

int main()
{
    signal(2, handler);
    printf("%d\n", getpid());
    while(!flag);
    printf("进程结束\n");

    return 0;
}